/**
 * @param {number[]} scores
 * @param {number[]} ages
 * @return {number}
 */
var bestTeamScore = function (scores, ages) {
  let arr = new Map(),
    sum = 0,
    flag
  bc(0)

  function bc(index) {
    if (arr.size != 0) {
      sum = Math.max(
        sum,
        [...arr.values()].reduce((pre, cur) => scores[pre] + scores[cur])
      )
    }

    for (let i = index; i < ages.length; i++) {
      flag = false
      for (const [k, v] of arr) {
        if (ages[i] < k) {
          if (scores[i] >= scores[v]) {
            flag = true
            break
          }
        }
      }
      if (flag) continue

      arr.set(ages[i], i)
      bc(i + 1)
      arr.delete(ages[i])
    }
  }

  console.log(123)
}

bestTeamScore([1, 2, 3, 5], [8, 9, 10, 1])
